#include <queue>
using namespace std;
// 堆 top k
class Solution
{
public:
    int findKthLargest(vector<int> &nums, int k)
    {
        priority_queue<int, vector<int>, greater<int>> heap;
        for (auto e : nums)
        {
            heap.push(e);
            if (heap.size() > k)
                heap.pop();
        }
        return heap.top();
    }
};
#include <algorithm>
using namespace std;
// 解法二 排序
class Solution
{
public:
    int findKthLargest(vector<int> &nums, int k)
    {
        sort(nums.begin(), nums.end(), greater<int>());
        return nums[k - 1];
    }
};